home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / Internet / WWW / Perl_WWW_Utilities / perlMIF_beta2 / mif / mif_char.pl next >
Encoding:
Perl Script  |  1994-05-18  |  4.2 KB  |  125 lines

  1. ##---------------------------------------------------------------------------##
  2. ##  File:
  3. ##      mif_char.pl
  4. ##  Author:
  5. ##      Earl Hood       ehood@convex.com
  6. ##  Description:
  7. ##    This file is defines the "mif_char" perl package.  It defines
  8. ##    routines to handle Char via MIFread_mif() defined in
  9. ##    the "mif" package.
  10. ##---------------------------------------------------------------------------##
  11. ##  Copyright (C) 1994  Earl Hood, ehood@convex.com
  12. ##
  13. ##  This program is free software; you can redistribute it and/or modify
  14. ##  it under the terms of the GNU General Public License as published by
  15. ##  the Free Software Foundation; either version 2 of the License, or
  16. ##  (at your option) any later version.
  17. ## 
  18. ##  This program is distributed in the hope that it will be useful,
  19. ##  but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. ##  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  21. ##  GNU General Public License for more details.
  22. ##  
  23. ##  You should have received a copy of the GNU General Public License
  24. ##  along with this program; if not, write to the Free Software
  25. ##  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  26. ##---------------------------------------------------------------------------##
  27.  
  28. require 'mif/mif.pl' || die "Unable to require mif.pl\n";
  29.  
  30. package mif_char;
  31.  
  32. ##--------------------------------------##
  33. ## Add Chat routine to %MIFToken array ##
  34. ##--------------------------------------##
  35. $mif'MIFToken{'Char'} = "Char";
  36.  
  37. ##--------------------##
  38. ## mif_font variables ##
  39. ##--------------------##
  40. $char_close_func = "";    # Function to call after Char statement.
  41.  
  42. ##---------------------------------------##
  43. ## Variables for current Char definition ##
  44. ##---------------------------------------##
  45. $Char        = "";
  46.  
  47. ##------------------------##
  48. ## Import 'mif' variables ##
  49. ##------------------------##
  50. $MStore        = $mif'MStore;
  51. $MOpen        = $mif'MOpen;
  52. $MClose        = $mif'MClose;
  53. $MLine        = $mif'MLine;
  54. $mso        = $mif'mso;
  55. $msc        = $mif'msc;
  56. $stb        = $mif'stb;
  57. $ste        = $mif'ste;
  58. $como        = $mif'como;
  59.  
  60.                 ##---------------##
  61.                 ## Main Routines ##
  62.                 ##---------------##
  63. ##---------------------------------------------------------------------------
  64. ##    MIFget_char_func() returns the function that is called when the
  65. ##    Char statement closes.
  66. ##
  67. ##    Usage:
  68. ##        $func = &'MIFget_char_func();
  69. ##
  70. sub main'MIFget_char_func {
  71.     $char_close_func;
  72. }
  73. ##---------------------------------------------------------------------------
  74. ##    MIFset_char_func() sets the function that is called when the
  75. ##    Char statement closes.
  76. ##
  77. ##    Usage:
  78. ##        &'MIFset_char_func($func);
  79. ##
  80. sub main'MIFset_tab_func {
  81.     $char_close_func = shift;
  82. }
  83. ##---------------------------------------------------------------------------
  84. ##    MIFwrite_char() outputs the Char in MIF.
  85. ##
  86. ##    Usage:
  87. ##        &'MIFwrite_char(FILEHANDLE, $indent, $name);
  88. ##
  89. sub main'MIFwrite_char {
  90.     local($handle, $l, $name) = @_;
  91.     local($i0, $i1, $i2) = (' ' x $l, ' ' x (1+$l), ' ' x (2+$l));
  92.  
  93.     print $handle $i0, $mso, 'Char ' , $name, $msc, "\n";;
  94. }
  95. ##---------------------------------------------------------------------------##
  96. ##    MIFget_last_char_data() is a convienence routine that returns the
  97. ##    data associated with the last Char statement.  This routine
  98. ##    is mainly used by other mif_* libraries that need to process
  99. ##    Char statements.
  100. ##
  101. ##    Usage:
  102. ##        ($char_name) = &'MIFget_last_char_data();
  103. ##
  104. sub main'MIFget_last_char_data {
  105.     ($Char);
  106. }
  107. ##---------------------------------------------------------------------------##
  108.                 ##--------------##
  109.                 ## Mif Routines ##
  110.                 ##--------------##
  111. ##---------------------------------------------------------------------------##
  112. ##    The routines definded below are all registered in the %MIFToken         ##
  113. ##    array for use in the MIFread_mif() routine.  There purpose is to     ##
  114. ##    store the information contained in a Char statement.             ##
  115. ##---------------------------------------------------------------------------##
  116.  
  117. ##---------------------------------------------------------------------------
  118. sub Char {
  119.     local($token, $mode, *data) = @_;
  120.     ($Char) = $data =~ /^\s*(.*)$/o;
  121.     &$char_close_func($Char) if $char_close_func;
  122. }
  123. ##---------------------------------------------------------------------------
  124. 1;
  125.